<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<jsp:include page="/admin/jsp/common/HtmlHead.jsp"/>
	<title>欢迎登录</title>
	<script type="text/javascript">
	function onsubmit(){
		var btn = document.getElementById('btn_sub');
		var loginName = document.getElementById('loginName');
		var pwd = document.getElementById('pwd');
		var validateCode = document.getElementById('validateCode');
		var errormsg = document.getElementById('error_msg');
		if(loginName.value==''){
			errormsg.innerHTML = '请输入用户名';
			loginName.focus();
			return;
		}
		if(loginName.value.length>128){
			errormsg.innerHTML = '用户名字符长度不能超过128';
			loginName.focus();
			return;
		}
		if(pwd.value==''){
			errormsg.innerHTML = '请输入密码';
			pwd.focus();
			return;
		}
		if(pwd.value.length>128){
			errormsg.innerHTML = '密码字符长度不能超过128';
			pwd.focus();
			return;
		}
		if(validateCode.value==''){
			errormsg.innerHTML = '请输入验证码';
			validateCode.focus();
			return;
		}
		if(validateCode.value.length>4){
			errormsg.innerHTML = '验证码字符长度不能超过4';
			validateCode.focus();
			return;
		}
		btn.click();
	}
	function setmid(){
		var clientHeight = document.documentElement.clientHeight;
		var loginbox = document.getElementById('login_box');
		var h = loginbox.clientHeight;
		var paddTop = (clientHeight-h)/2*0.75;
		if(paddTop>0){
			document.body.style.paddingTop=paddTop+"px";
		}
	}
	window.onload = setmid;
	window.onresize = setmid;
	</script>
</head>
<body id="login_bd">
	<div id="login_box">
	<s:form method="post" action="loginDo" id="myForm" target="_top" namespace="/admin/login">
		<div class="box_input">
			<ul>
				<li><span class="tit">用户名:</span></li>
				<li><div class="input_ctn"><s:textfield id="loginName" name="loginName" cssClass="txt"/></div></li>
				<li><span class="tit">密&nbsp;&nbsp;码:</span></li>
				<li><div class="input_ctn"><input type="password" id="pwd" name="pwd" class="txt"/></div></li>
				<li><span class="tit">验证码:</span></li>
				<li><div class="input_ctn" style="width:84px;float:left;margin-right:6px;"><input id="validateCode" name="validateCode" maxlength="4" type="text" class="txt" style="width:80px;"/></div>
					<img style="width:80px;height:30px;cursor: pointer;" src="<%=basePath%>imageServlet" title="点击重新获取验证码" onclick="this.src='<%=basePath%>imageServlet?'+(new Date()).getTime();"/>
				</li>
			</ul>
		</div>
		<div class="box_btm">
			<em class="error_msg" id="error_msg"><s:actionerror escape="false"/></em>
			<a class="btn" style="float:right;margin:18px 0 0 0;" href="javascript:onsubmit();"><span>登&nbsp;录</span></a>
			<input type="submit" style="display:none;" value="登录" id="btn_sub"/>
		</div>
	</s:form>
	</div>
</body>
</html>